# -*- coding: UTF-8 _*_

import allure
from common.webbase import WebBase


loc_h = ('xpath', '//*[@id="menuMainNav"]/li[8]/a/span')
adminiframe = 'appIframe-admin'

class houtaipage():
    @allure.step('打开后台页面')
    def open_page(self, driver, check='', pagename='', elename=''):
        hou = WebBase(driver)
        # 执行后面校验判断后，iframe被切换，导致后续用例无法执行。刷新回到最原始状态
        hou.refresh()
        hou.click(locator=loc_h, pagename=pagename, elename=elename)
        r = hou.istitle(check=check, pagename=pagename)
        # hou.save_myscreenshot(pagename=pagename)
        return r

    @allure.step('切换iframe')
    def switch_to_iframe(self, driver, pagename='', iframename=''):
        hou = WebBase(driver)
        hou.switchiframe(iframe=adminiframe, pagename=pagename, iframename=iframename)

    @allure.step('检查对应文本')
    def houtai_check(self, driver, loc='', check='', pagename=''):
        hou = WebBase(driver)
        t = hou.istext(locator=loc, check=check, pagename=pagename)
        return t
